import spacy
from spacy import displacy
nlp=spacy.load('en_core_web_sm')
def helper(s,p):
    s_split=s.split()
    p_split=p.split()
    ans=[]
    i=0
    while i<len(s_split):
        tmp_i=i
        j=0
        while tmp_i < len(s_split) and j <len(p_split) and s_split[tmp_i]==p_split[j]:
            tmp_i+=1
            j+=1
        if j==len(p_split):
            for p in p_split:
                ans.append(p+"/B")
            i=tmp_i
        else:
            ans.append(s_split[i]+"/I")
            i+=1
    return  ans
doc=nlp('good my night my son son. i love you my son son really. it is ture really. my favourit apple is big apple son.')
list=[]
list2=[]
aa='my son'
for token in doc.sents:
    if aa in str(token):
        list2.extend(helper(str(token),aa))
        list.extend(list2+["./O"] )
        list2.clear()
    else:
        for res in token:
            list.append(res.text+"/O")
print(doc)
print(" ".join(list))

